home *** CD-ROM | disk | FTP | other *** search
- /***********************************************
- *
- * CodeDispatchLib.c
- *
- * Library code and dispatch table for code resource library.
- * Written by David Burggraaf, 1990.
- *
- ***********************************************/
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- #define NOCODELIBDEF
- #include "CodeLib.h"
-
- /*#define MULTISEG*/
-
- typedef void (*Function)(void);
-
- long returnAddr, oldA4;
- int funcIndex;
- void dispatchErr(void);
- Function funcTable[ROUTINES+1];
-
- void main(/*CodeLib routine*/void)
- {
- asm {
- move.l a4, a1; /* setup a4 */
- move.l a0, a4;
- move.l a1, oldA4;
- };
- funcTable[CLdispatchErr]=dispatchErr;
- funcTable[CLatoi]=(Function)atoi;
- funcTable[CLatol]=(Function)atol;
- funcTable[CLsprintf]=(Function)sprintf;
- funcTable[CLsrand]=(Function)srand;
- funcTable[CLstrcpy]=(Function)strcpy;
- asm {
- move.l (a7)+, returnAddr; /* save return address */
- move.w (a7)+, a1; /* remove index */
- lea funcTable, a0; /* do jump to indexed subroutine */
- jsr ([0,a0,a1.w*4],0);
- move.w a1, -(a7); /* restore stack and return */
- move.l returnAddr, -(a7);
- move.l oldA4, a4; /* restore a4 */
- }
- #ifdef MULTISEG
- UnloadA4Seg(0L);
- #endif
- }
-
- void dispatchErr(void)
- {
- SysBeep(5);
- }
-
-